package com_.dxy_test_.redis_;

import io.lettuce.core.api.sync.RedisCommands;
import redis.clients.jedis.Jedis;

/**
 * @Description TODO
 * @Author dangxianyue
 * @Date 2022/11/8 18:25
 */
public class RedisTest {

    public static void main(String[] args) {

        testLettuce();
    }

    private static void testJedis() {
        final Jedis jedis = RedisConfig.jedis;
        Long decr = jedis.decr("dxy-decr");
        System.out.println("decr: " + decr);
        decr = jedis.decr("dxy-decr");
        System.out.println("decr: " + decr);

        Long incr = jedis.incr("dxy-incr");
        System.out.println("incr: " + incr);
        incr = jedis.incr("dxy-incr");
        System.out.println("incr: " + incr);
    }

    private static void testLettuce() {
        RedisCommands<String, String> syncCommands = RedisConfig.syncCommands;

        Long number = Long.parseLong(syncCommands.get("dxy-decr-1"));
        System.out.println("number: " + number);


        Long decr = syncCommands.decr("dxy-decr-1");
        System.out.println("lettuce decr: " + decr);
        decr = syncCommands.decr("dxy-decr-1");
        System.out.println("lettuce decr: " + decr);

        number = Long.parseLong(syncCommands.get("dxy-decr-1"));
        System.out.println("number: " + number);
    }
}
